Imports System.Xml.Serialization

Public Class Runtime
    Inherits XEntityModelElementBase

    ''' <summary>Initializes an instance of the <see cref="Runtime" /> class.
    ''' This is the default constructor for this class.</summary>
    Public Sub New()
        MyBase.New("RunTime", EdmxXmlNamespace)
    End Sub

    ''' <summary>Initializes an instance of the <see cref="Runtime" /> class.</summary>
    ''' <param name="other">An <see cref="System.Xml.Linq.XElement"/> object to copy from.</param>
    Public Sub New(ByVal other As XElement)
        MyBase.New(other)
    End Sub

    <AutoLoad()> _
    <XmlElement("StorageModels")> _
    Public Property StorageModels() As RuntimeStorageModels
        Get
            Return DirectCast(Me.Element(MyBase.Name.Namespace + "StorageModels"), EdmxEditor.RuntimeStorageModels)
        End Get
        Set(ByVal value As RuntimeStorageModels)
            If (DirectCast(value, XElement).Name <> (MyBase.Name.Namespace + "StorageModels")) Then
                Throw New ArgumentException("Invalid Element")
            End If
            If (Me.StorageModels IsNot Nothing) Then
                Me.StorageModels.Remove()
            End If
            Me.Add(New EdmxEditor.RuntimeStorageModels(value))
            If (Me.StorageModels Is Nothing) Then
                Me.Add(value)
            Else
                Me.StorageModels.ReplaceAll(value.Nodes)
            End If
        End Set
    End Property

    <AutoLoad()> _
    <XmlElement("ConceptualModels")> _
    Public Property ConceptualModels() As RuntimeConceptualModels
        Get
            Return DirectCast(Me.Element(MyBase.Name.Namespace + "ConceptualModels"), EdmxEditor.RuntimeConceptualModels)
        End Get
        Set(ByVal value As RuntimeConceptualModels)
            If (DirectCast(value, XElement).Name <> (MyBase.Name.Namespace + "ConceptualModels")) Then
                Throw New ArgumentException("Invalid Element")
            End If
            If (Me.ConceptualModels IsNot Nothing) Then
                Me.ConceptualModels.Remove()
            End If
            Me.Add(New EdmxEditor.RuntimeConceptualModels(value))
        End Set
    End Property

    <AutoLoad()> _
    <XmlElement("Mappings")> _
    Public Property Mappings() As RuntimeMappings
        Get
            Return DirectCast(Me.Element(MyBase.Name.Namespace + "Mappings"), EdmxEditor.RuntimeMappings)
        End Get
        Set(ByVal value As RuntimeMappings)
            If (DirectCast(value, XElement).Name <> (MyBase.Name.Namespace + "Mappings")) Then
                Throw New ArgumentException("Invalid Element")
            End If
            If (Me.Mappings IsNot Nothing) Then
                Me.Mappings.Remove()
            End If
            Me.Add(New EdmxEditor.RuntimeMappings(value))
        End Set
    End Property

End Class

